# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=graphw00f
pkgver=1.2.1.r2.gb4096a8
pkgrel=1
pkgdesc='GraphQL endpoint detection and engine fingerprinting.'
arch=('any')
groups=('blackarch' 'blackarch-webapp' 'blackarch-fingerprint')
url='https://github.com/dolevf/graphw00f'
license=('BSD')
depends=('python' 'python-requests')
makedepends=('git')
source=("git+https://github.com/dolevf/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md

  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a *.py $pkgname "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
python ./main.py "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/$pkgname"
}

